package com.sunyard.auth.service.convert;

import com.google.common.collect.Lists;
import com.sunyard.auth.dal.dataobject.SmAuthUserDO;
import com.sunyard.auth.service.bo.SmAuthUserBO;
import org.apache.commons.collections.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * @program auth
 * @description
 * @author raoinyx@163.com
 * @create 2020-07-18 00:23
 */
public class SmAuthUserConvert {
	public static SmAuthUserBO toBO(SmAuthUserDO washCarMemberCouponDO) {
		if (washCarMemberCouponDO == null) {
			return null;
		}
		SmAuthUserBO smAuthUserBO = new SmAuthUserBO();
		smAuthUserBO.setUserId(washCarMemberCouponDO.getUserId());
		smAuthUserBO.setUserName(washCarMemberCouponDO.getUserName());
		smAuthUserBO.setPassword(washCarMemberCouponDO.getPassword());
		smAuthUserBO.setRealName(washCarMemberCouponDO.getRealName());
		smAuthUserBO.setTelephone(washCarMemberCouponDO.getTelephone());
		smAuthUserBO.setEmail(washCarMemberCouponDO.getEmail());
		smAuthUserBO.setStatus(washCarMemberCouponDO.getStatus());
		smAuthUserBO.setOrgcode(washCarMemberCouponDO.getOrgcode());
		return smAuthUserBO;
	}

	public static SmAuthUserDO toDO(SmAuthUserBO washCarMemberCouponBO) {
		if (washCarMemberCouponBO == null) {
			return null;
		}
		SmAuthUserDO smAuthUserDO = new SmAuthUserDO();
		smAuthUserDO.setUserId(washCarMemberCouponBO.getUserId());
		smAuthUserDO.setUserName(washCarMemberCouponBO.getUserName());
		smAuthUserDO.setPassword(washCarMemberCouponBO.getPassword());
		smAuthUserDO.setRealName(washCarMemberCouponBO.getRealName());
		smAuthUserDO.setTelephone(washCarMemberCouponBO.getTelephone());
		smAuthUserDO.setEmail(washCarMemberCouponBO.getEmail());
		smAuthUserDO.setStatus(washCarMemberCouponBO.getStatus());
		smAuthUserDO.setOrgcode(washCarMemberCouponBO.getOrgcode());
		return smAuthUserDO;
	}

	public static List<SmAuthUserBO> toBOList(List<SmAuthUserDO> doList) {
        if (CollectionUtils.isEmpty(doList)) {
			return Collections.emptyList();
		}
		List<SmAuthUserBO> boList = Lists.newArrayList();
		for (SmAuthUserDO smAuthUserDO : doList) {
			if (smAuthUserDO != null) {
				boList.add(toBO(smAuthUserDO));
			}
		}
		return boList;
	}

}
